<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>寻找峰值</title>
</head>

<body>
  <script>
    function find(arr) {
      let result = 0;
      for (let i = 1; i < arr.length; i++) {
        if (arr[i] > arr[result]) {
          result = i;
        }
      }
      return result;
    }
    console.log(find([1, 2, 3, 2, 5, 4]));
  </script>
</body>

</html>